#############################################
##### Replication Code
##### Mobilizing for Prisoner Release During a Pandemic via Perspective-Taking Exercises: Appendix 2
##### Mackenzie Israel-Trummel
#############################################

##First run the replication file for the Manuscript 



###############
##Intercoder Reliability
###############


library(irr)

names(covid)

##coding to binary release yes/no

covid$Jack_recode[covid$Jack == 1] <- 1
covid$Jack_recode[covid$Jack == 2] <- 0
table(covid$Jack, covid$Jack_recode)

covid$Alison_recode[covid$Alison == 1] <- 1
covid$Alison_recode[covid$Alison == 2] <- 0
table(covid$Alison, covid$Alison_recode)

covid$Sydney_recode[covid$Sydney == 1] <- 1
covid$Sydney_recode[covid$Sydney == 2] <- 0
table(covid$Sydney, covid$Sydney_recode)

covid$Kevin_recode[covid$Kevin == 1] <- 1
covid$Kevin_recode[covid$Kevin == 2] <- 0
table(covid$Kevin, covid$Kevin_recode)

covid$Sophie_recode[covid$Sophie == 1] <- 1
covid$Sophie_recode[covid$Sophie == 2] <- 0
table(covid$Sophie, covid$Sophie_recode)

covid$Mackenzie_recode[covid$Mackenzie == 1] <- 1
covid$Mackenzie_recode[covid$Mackenzie == 2] <- 0
table(covid$Mackenzie, covid$Mackenzie_recode)


##coding to three levels: release yes/no and everything else

covid$Jack_recode2[covid$Jack == 1] <- 1
covid$Jack_recode2[covid$Jack == 2] <- 0
covid$Jack_recode2[covid$Jack > 2] <- 99
table(covid$Jack, covid$Jack_recode2)

covid$Alison_recode2[covid$Alison == 1] <- 1
covid$Alison_recode2[covid$Alison == 2] <- 0
covid$Alison_recode2[covid$Alison > 2] <- 99
table(covid$Alison, covid$Alison_recode2)

covid$Sydney_recode2[covid$Sydney == 1] <- 1
covid$Sydney_recode2[covid$Sydney == 2] <- 0
covid$Sydney_recode2[covid$Sydney > 2] <- 99
table(covid$Sydney, covid$Sydney_recode2)

covid$Kevin_recode2[covid$Kevin == 1] <- 1
covid$Kevin_recode2[covid$Kevin == 2] <- 0
covid$Kevin_recode2[covid$Kevin > 2] <- 99
table(covid$Kevin, covid$Kevin_recode2)

covid$Sophie_recode2[covid$Sophie == 1] <- 1
covid$Sophie_recode2[covid$Sophie == 2] <- 0
covid$Sophie_recode2[covid$Sophie > 2] <- 99
table(covid$Sophie, covid$Sophie_recode2)

covid$Mackenzie_recode2[covid$Mackenzie == 1] <- 1
covid$Mackenzie_recode2[covid$Mackenzie == 2] <- 0
covid$Mackenzie_recode2[covid$Mackenzie > 2] <- 99
table(covid$Mackenzie, covid$Mackenzie_recode2)



##subsets of first training round

first <- subset(covid, id < 203)
summary(first$id)

second <- subset(covid, id > 202 & id < 703)
summary(second$id)

##subset to group that did 703-1374
third.A <- subset(covid, id > 702 & id < 1375)
summary(third.A$id)

##subset to group that did 1375-2047
third.B <- subset(covid, id > 1374)
summary(third.B$id)


##Kappas on rounds

##round 1
kappam.fleiss(first[, c("Jack", "Alison", "Sydney", "Kevin", "Sophie", "Mackenzie")]) ##kappa = 0.741
kappam.fleiss(first[, c("Jack_recode2", "Alison_recode2", "Sydney_recode2", "Kevin_recode2", "Sophie_recode2", "Mackenzie_recode2")])  ##kappa = 0.818
kappam.fleiss(first[, c("Jack_recode", "Alison_recode", "Sydney_recode", "Kevin_recode", "Sophie_recode", "Mackenzie_recode")])  ##kappa = 0.947


##round 2
kappam.fleiss(second[, c("Jack", "Alison", "Sydney", "Kevin", "Sophie", "Mackenzie")]) ##kappa = 0.795
kappam.fleiss(second[, c("Jack_recode2", "Alison_recode2", "Sydney_recode2", "Kevin_recode2", "Sophie_recode2", "Mackenzie_recode2")])  ##kappa = 0.848
kappam.fleiss(second[, c("Jack_recode", "Alison_recode", "Sydney_recode", "Kevin_recode", "Sophie_recode", "Mackenzie_recode")])  ##kappa = 0.933

##round 3A
kappam.fleiss(third.A[, c("Jack", "Alison", "Sophie", "Mackenzie")]) ##kappa = 0.709
kappam.fleiss(third.A[, c("Jack_recode2", "Alison_recode2", "Sophie_recode2", "Mackenzie_recode2")])  ##kappa = 0.803
kappam.fleiss(third.A[, c("Jack_recode", "Alison_recode", "Sophie_recode", "Mackenzie_recode")])  ##kappa = 0.842


##round 3B
kappam.fleiss(third.B[, c("Sydney", "Kevin", "Mackenzie")]) ##kappa = 0.797
kappam.fleiss(third.B[, c("Sydney_recode2", "Kevin_recode2", "Mackenzie_recode2")])  ##kappa = 0.862
kappam.fleiss(third.B[, c("Sydney_recode", "Kevin_recode", "Mackenzie_recode")])  ##kappa = 0.912


##overall kappas

kappam.fleiss(covid[, c("Jack", "Alison", "Sydney", "Kevin", "Sophie", "Mackenzie")])
kappam.fleiss(covid[, c("Jack_recode2", "Alison_recode2", "Sydney_recode2", "Kevin_recode2", "Sophie_recode2", "Mackenzie_recode2")])
kappam.fleiss(covid[, c("Jack_recode", "Alison_recode", "Sydney_recode", "Kevin_recode", "Sophie_recode", "Mackenzie_recode")])


##How many of the respondents analyzed in manuscript had their responses changed by reconciliation compared to modal coding? 
table(covid.white$Modal, covid.white$Reconciled) ##78 respondents differ in these codings

##32 statements received a support/oppose coding in modal and were changed in reconciliation: 2.9 percent of statements (1116 statements coded)

##20 statements that were coded as unclear, unsure, refusal, gibberish in the modal scheme got recoded as support or oppose in reconciliation: 1.8 percent of statements
